//
// Created by klen on 23-11-27.
//
#include <memory>  // for allocator, __shared_ptr_access, shared_ptr
#include <string>  // for string, basic_string
#include <vector>  // for vector

#include "ftxui/component/captured_mouse.hpp"  // for ftxui
#include "ftxui/component/component.hpp"  // for Radiobox, Horizontal, Menu, Renderer, Tab
#include "ftxui/component/component_base.hpp"      // for ComponentBase
#include "ftxui/component/screen_interactive.hpp"  // for ScreenInteractive
#include "ftxui/dom/elements.hpp"  // for Element, separator, hbox, operator|, border


int main() {
    using namespace ftxui;

    // 准备选项
    std::vector<std::string> option = {"选项1", "选项2", "选项3"};

    int selected = 0;

    // 创建下拉框
    auto dropdown = Dropdown(&option, &selected);

    auto dom = Renderer(dropdown, [&]{
        return vbox({
                            hbox({
                                         text("selected: "),
                                         text(std::to_string(selected)),
                                 }),
                            separator(),
                            dropdown->Render(),
                    });
    });


    // 创建一个全屏交互屏幕
    auto screen = ScreenInteractive::Fullscreen();

    // 将页面输出到屏幕上
    screen.Loop(dom);
}